a simply testing script for v2ray only on centos7¶
you should run it before this.
#!/bin/bash echo "=================================================" echo "a simply testing script for v2ray only on centos7" echo " author:chenshi " echo "=================================================" if [ -d /usr/local/v2ray ];then rm -rf /usr/local/v2ray && kill -9 `ps -ef|grep v2ray|grep -v grep|awk {'print $2'}` > /dev/null 2>&1 fi read -p "please input your domain:" domain # ensure selinux is disabled sed -i 's/^SELINUX=.*$/SELINUX=disabled/g' /etc/selinux/config setenforce 0 # install server # python -c 'import yum, pprint; a = yum.YumBase(); pprint.pprint(a.conf.yumvar, width=1)'|grep releasever yum install epel-release -y yum --installroot=/usr/local/v2ray/software --releasever=7 install caddy unzip bc ca-certificates -y getVersion(){ a=`curl -s "https://github.com/v2ray/v2ray-core/releases/latest"` b=${a:84} echo ${b%%\"*} } # curl -H "Cache-Control: no-cache" -s -L -o /usr/local/v2ray/software/v2ray-linux-64.zip https://github.com/v2ray/v2ray-core/releases/download/$(getVersion)/v2ray-linux-64.zip curl -H "Cache-Control: no-cache" -s -L -o /usr/local/v2ray/software/v2ray-linux-64.zip https://github.com/v2fly/v2ray-core/releases/download/v4.31.0/v2ray-linux-64.zip /usr/local/v2ray/software/bin/unzip /usr/local/v2ray/software/v2ray-linux-64.zip -d /usr/local/v2ray/software/v2ray # prepare configure files UUID=`uuidgen` alterId=`echo $RANDOM%35+65|/usr/local/v2ray/software/bin/bc` mkdir -p /usr/local/v2ray/conf/ cat << EOF > /usr/local/v2ray/conf/Caddyfile $domain { log /usr/local/v2ray/software/caddy.log proxy /${domain%%.*} localhost:10800 { websocket header_upstream -Origin } } EOF cat << EOF > /usr/local/v2ray/conf/server.json { "inbounds": [ { "port": 10800, "listen":"127.0.0.1", "protocol": "vmess", "settings": { "clients": [ { "id": "$UUID", "alterId": $alterId } ] }, "streamSettings": { "network": "ws", "wsSettings": { "path": "/${domain%%.*}" } } } ], "outbounds": [ { "protocol": "freedom", "settings": {} } ] } EOF cat << EOF > /usr/local/v2ray/conf/client.json { "inbounds": [ { "port": 1080, "listen": "0.0.0.0", "protocol": "socks", "sniffing": { "enabled": true, "destOverride": ["http", "tls"] }, "settings": { "auth": "noauth", "udp": false } } ], "outbounds": [ { "protocol": "vmess", "settings": { "vnext": [ { "address": "$domain", "port": 443, "users": [ { "id": "$UUID", "alterId": $alterId } ] } ] }, "streamSettings": { "network": "ws", "security": "tls", "wsSettings": { "path": "/${domain%%.*}" } } } ] } EOF # start server nohup /usr/local/v2ray/software/v2ray/v2ray -config /usr/local/v2ray/conf/server.json > /dev/null 2>&1 & nohup sh -c "echo -e '\n'|/usr/local/v2ray/software/bin/caddy -conf /usr/local/v2ray/conf/Caddyfile -agree" > /dev/null 2>&1 & echo "=======================================================================" echo "download /usr/local/v2ray/conf/client.json to your pc or another server" echo " visit https://chenshi.de to learn more " echo "======================================================================="